package com.gsoe.judge.controller;

import com.gsoe.base.model.PageResult;
import com.gsoe.base.model.Result;
import com.gsoe.dto.CheckProblemAnswerDTO;
import com.gsoe.dto.ProblemRecordDTO;
import com.gsoe.judge.service.JudgeService;
import com.gsoe.po.Judge;
import com.gsoe.vo.JudgeVO;
import com.gsoe.vo.ProblemRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户刷题记录 前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2024-11-04
 */
@RestController
@RequestMapping("/judge")
public class JudgeController {

    @Autowired
    private JudgeService judgeService;

    @PostMapping("/submitAnswer")
    public Result<JudgeVO> submitAnswer(@RequestBody CheckProblemAnswerDTO checkProblemAnswerDTO) {
        return Result.success(judgeService.submitAnswer(checkProblemAnswerDTO));
    }

    @PostMapping("/getProblemRecord")
    public Result<PageResult<ProblemRecordVO>>getProblemRecord(@RequestBody ProblemRecordDTO problemRecordDTO) {
        PageResult<ProblemRecordVO> problemRecord = judgeService.getProblemRecord(problemRecordDTO);
        return Result.success(problemRecord);
    }

    @GetMapping("/getProblemNumberByDiff/{userId}")
    public Result<List<Judge>> getProblemNumberByDiff(@PathVariable Long userId){
        List<Judge> judgeList =judgeService.getProblemNumber(userId);
        return Result.success(judgeList);
    }
}
